<template>
  <a-card :bordered="false">
  <!-- 查询区域 -->
  <div class="table-page-search-wrapper">
    <a-form layout="inline" @keyup.enter.native="searchQuery">
      <a-row :gutter="24">


          <a-col :md="6" :sm="8">
            <a-form-item :label="$t('seek.seekSchool.labelStudentName')">
              <j-input :placeholder="$t('seek.seekSchool.inputStudentName')" v-model="queryParam.studentName"></j-input>
            </a-form-item>
          </a-col>

        <a-col :md="6" :sm="8">
          <a-form-item label="性别">
            <j-dict-select-tag v-model="queryParam.gender"  :placeholder="$t('seek.seekSchool.selectSex')" dictCode="sex"/>
          </a-form-item>
        </a-col>

        <template v-if="toggleSearchStatus">


          <a-col :md="6" :sm="8">
            <a-form-item :label="$t('seek.seekSchool.labelSeekerIdentity')">
              <j-dict-select-tag v-model="queryParam.seekerIdentity"
                                 :placeholder="$t('seek.seekSchool.seekerIdentity')"   dictCode="seekerIdentity"/>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-model-item :label="$t('seek.seekSchool.titleIssueType')">
<!--              <j-dict-select-tag v-model="queryParam.issueType" :placeholder="$t('seek.seekSchool.inputIssueType')"-->
<!--                                 dictCode="issueType"/>-->
              <j-tree-dict parent-code="B04" v-model="queryParam.issueType"
                           :placeholder="$t('seek.seekSchool.inputIssueType')"  field="id" ></j-tree-dict>
            </a-form-model-item>
          </a-col>
        </template>

        <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">{{$t('seek.seekSchool.btnSearch')}}</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展開' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
        </a-col>

      </a-row>
    </a-form>
  </div>


    <!-- 操作按钮区域 -->
    <div class="table-operator" style="border-top: 5px">
      <a-button @click="handleAdd" type="primary" icon="plus" >添加</a-button>

      <a-button type="primary" icon="download" @click="handleExportXls('求助咨詢列表')">{{$t('seek.seekSchool.btnExport')}}</a-button>

      <!--          <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">-->
      <!--            <a-button type="primary" icon="import">导入</a-button>-->
      <!--          </a-upload>-->
      <!--          <j-third-app-button biz-type="user" :selected-row-keys="selectedRowKeys" syncToApp syncToLocal @sync-finally="onSyncFinally"/>-->





      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay" @click="handleMenuClick">
          <a-menu-item key="1">
            <a-icon type="delete" @click="batchDel"/>
            {{ $t('seek.seekSchool.btnDelete')}}
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px">
          批量操作
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>


    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i>{{$t('seek.seekSchool.iSelectd')}}&nbsp;<a style="font-weight: 600">{{ selectedRowKeys.length }}</a>{{$t('seek.seekSchool.item')}}&nbsp;&nbsp;
        <a style="margin-left: 24px" @click="onClearSelected"></a>
      </div>

      <a-table
        ref="table"
        bordered
        size="middle"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange"
      >


<!--        <template slot="avatarslot" slot-scope="text, record, index">-->
<!--          <div class="anty-img-wrap">-->
<!--            <a-avatar shape="square" :src="getAvatarView(record.avatar)" icon="user"/>-->
<!--          </div>-->
<!--        </template>-->


        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)" >{{$t('seek.seekSchool.btnEdit')}}</a>

          <a-divider type="vertical" />

          <a-dropdown>
            <a class="ant-dropdown-link">
              更多 <a-icon type="down"/>
            </a>
            <a-menu slot="overlay">

              <a-menu-item>
                <a-popconfirm :title="$t('seek.seekSchool.confirmDelete')" @confirm="() => handleDelete(record.id)">
                  <a>      {{ $t('seek.seekSchool.btnDelete')}}</a>
                </a-popconfirm>
              </a-menu-item>

            </a-menu>
          </a-dropdown>
        </span>


      </a-table>
    </div>


    <SeekModel ref="modalForm" @ok="modalFormOk"></SeekModel>


  </a-card>
</template>

<script>
import SeekModel from './modules/SeekModel'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {filterDictTextByCache} from '@/components/dict/JDictSelectUtil'
import JTreeDict from '../../components/jeecg/JTreeDict'
export default {
  name: "SeekList",
  mixins: [JeecgListMixin],
  components: {
    SeekModel,
    JTreeDict
  },
  data() {
    return {
      queryParam:{
        studentName:'',
        gender:'',
        seekerIdentity:''
      },
      columns: [
        // {
        //   title: '編號',
        //   dataIndex: '',
        //   key:'rowIndex',
        //   width:60,
        //   align:"center",
        //   customRender:function (t,r,index) {
        //     return parseInt(index)+1;
        //   }
        // },
        {
          title: this.$t('seek.seekSchool.titleNo'),
          align: "center",
          dataIndex: 'consultationNo',
          width: 125,
          // sorter: true
        },
        {
          title: this.$t('seek.seekSchool.labelStudentName'),
          align: "center",
          width: 80,
          dataIndex: 'studentName',
        },
        {
          title: this.$t('seek.seekSchool.grade'),
          align: "center",
          width: 70,
          dataIndex: 'grade',
          customRender: (text) => {
            //字典值翻译通用方法
            return filterDictTextByCache('grade', text);
          }
        },

        {
          title: '性別',
          align: "center",
          width: 50,
          dataIndex: 'gender',
          customRender: (text) => {
            //字典值翻译通用方法
            return filterDictTextByCache('sex', text);
          }

        },
        // {
        //   title: '求助者'+this.$t('seek.seekSchool.name'),
        //   align: "center",
        //   dataIndex: 'seekerName',
        //   width: 70,
        // },
        {
          title: this.$t('seek.seekSchool.labelSeekerIdentity'),
          align: "center",
          width: 100,
          dataIndex: 'seekerIdentity',
          customRender: (text) => {
            //字典值翻译通用方法
            return filterDictTextByCache('seekerIdentity', text);
          }
        },
        {
          title: '其他身份',
          align: "center",
          width: 100,
          dataIndex: 'seekerIdentityOther',
        },
        {
          title: '求助'+this.$t('seek.seekSchool.means'),
          align: "center",
          width: 80,
          dataIndex: 'means',
          customRender: (text) => {
            //字典值翻译通用方法
            return filterDictTextByCache('means', text);
          }
        },
        {
          title: '其他'+this.$t('seek.seekSchool.means'),
          align: "center",
          width: 80,
          dataIndex: 'meansOther',
        },

        // {
        //   title: '出生日期',
        //   align: "center",
        //   width: 100,
        //   dataIndex: 'birthDate',
        //   sorter: true
        // },

        // {
        //   title: this.$t('seek.seekSchool.titleMethod'),
        //   align: "center",
        //   width: 105,
        //   dataIndex: 'tel',
        // },


        {
          title: this.$t('seek.seekSchool.titleSchoolName'),
          align: "center",
          width: 100,
          dataIndex: 'schoolName',
        },

        {
          title: this.$t('seek.seekSchool.titleConDate'),
          align: "center",
          width: 100,
          dataIndex: 'consultationDate',
          sorter: true
        },

        {
          title: this.$t('seek.seekSchool.titleIssueType'),
          align: "center",
          width: 105,
          dataIndex: 'issueType',
          customRender: (text) => {
            //字典值翻译通用方法
            return filterDictTextByCache('issueType', text);
          }
        },

        // {
        //   title: this.$t('seek.seekSchool.titleIssuePro'),
        //   align: "center",
        //   width: 70,
        //   dataIndex: 'issueProperty',
        //   customRender: (text) => {
        //     //字典值翻译通用方法
        //     return filterDictTextByCache('issueProperty', text);
        //   }
        // },


        // {
        //   title: '求助內容',
        //   align: "center",
        //   width: 100,
        //   dataIndex: 'content',
        // },
        // {
        //   title: this.$t('seek.seekSchool.titleIsOpenCase'),
        //   align: "center",
        //   width: 80,
        //   dataIndex: 'isOpenCase',
        //   customRender: (text) => {
        //     //字典值翻译通用方法
        //     return filterDictTextByCache('isOpenCase', text);
        //   }
        // },
        {
          title: this.$t('seek.seekSchool.creatorId'),
          align: "center",
          width: 100,
          dataIndex: 'creatorId',
        },
        {
          title: this.$t('seek.seekSchool.createTime'),
          align: "center",
          width: 100,
          dataIndex: 'createTime',
          sorter: true
        },
        {
          title: '操作',
          dataIndex: 'action',
          scopedSlots: {customRender: 'action'},
          align: "center",
          width: 170
        }

      ],
      url:{
        list: "/school/consult/seek/list",
        delete: "/school/consult/seek/delete",
        deleteBatch: "/school/consult/seek/deleteBatch",
        exportXlsUrl: "/school/consult/seek/exportXls"
      }
    }
  },
  created() {
    this.handleSeekList()
  },
  computed: {

  },
  methods: {

      handleSeekList(){
        console.log("加载救助页面")
        this.loadData()
      },
    //  handleDetail(record){
    //     console.log("record 的1 ==>",record)
    // }
    //处理菜单点击事件
    handleMenuClick(e) {
      if (e.key == 1) {
        this.batchDel();
      }
    },
  }

}
</script>
<style scoped>
@import '~@assets/less/common.less'
</style>